﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using TCKQKL.FrontEnd.DataModel;
using TCKQKL.Service.LookupClient;
using TCKQKL.FrontEnd.Config;

namespace TCKQKL.FrontEnd.Web.Controls
{
    public partial class MatchedRecently : System.Web.UI.UserControl
    {
        public List<MatchResultUI> orderMatchedData = new List<MatchResultUI>();

        protected void Page_Load(object sender, EventArgs e)
        {
            string userid = HttpContext.Current.User.Identity.Name;
            if (Settings.CHECK_ORDER_ALERT_EVERY_REQUEST || Cache[Settings.CACHE_KEY_MATCHED_ORDERSALERT + userid] == null)
            {
                LSClient client = new LSClient();
                orderMatchedData = client.getMatchedResultTopN(client.getAccountData(HttpContext.Current.User.Identity.Name).investorId, 5);
                client.Close();
                if (!Settings.CHECK_ORDER_ALERT_EVERY_REQUEST)
                {
                    Cache.Insert(Settings.CACHE_KEY_MATCHED_ORDERSALERT + userid, userid, null, System.DateTime.UtcNow.AddSeconds(Settings.ORDER_ALERT_CHECK_FREQUENCY), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
                }
            }

        }
    }
}